{% extends "common/nm_layout.html" %}
{% block content %}
    {% if data %}
        <table class="table table-hover add-wrap" style="text-align:center">
            <thead style="text-align:center">
            <tr>
                <th style="text-align:center; width:150px">Title</th>
                <th style="text-align:center; width:100px">Genre</th>
                <th style="text-align:center">Authors</th>
                <th style="text-align:center; width:120px">Link</th>
                <th style="text-align:center">Date</th>
                <th style="text-align:center">View</th>
                <th style="text-align:center">Operation</th>
            </tr>
            </thead>
            <tbody>
            <tr>
                <td><input type="text" name="title" style="width:150px" placeholder="新闻题目"></td>
                <td style="width:100px">
                    <input type="text" name="genre" style="width:100px" list="genre-list" placeholder="新闻类别">
                    <datalist id="genre-list">
                        <option>antip</option>
                        <option>ent</option>
                        <option>milite</option>
                        <option>world</option>
                        <option>tech</option>
                        <option>finance</option>
                    </datalist>
                </td>
                <td style="width:50px"><input type="text" style="width:100px" name="authors" placeholder="作者姓名">
                </td>
                <td>
                    <input type="text" style="width:120px" name="link" placeholder="来源网站">
                </td>
                <td><input type="text" name="date" value="{{ date }}"></td>
                <td><input type="text" name="view" placeholder="新闻阅览数"></td>
                <td>
                    <button class="label label-primary do-add">
                        commit
                    </button>
                </td>
            </tr>
            {% for item in data %}
                <tr>
                    <td>
                        <p style="width: 150px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">
                            <a href="{{ buildUrl("single")~"?id="~item.id }}">
                                {{ item.title }}
                            </a>
                        </p>
                    </td>
                    <td style="width: 100px;">{{ item.genres }}</td>
                    <td>{{ item.authors }}</td>
                    <td>
                        <a href="{{ item.link }}">
                            点击转到数据来源
                        </a>
                    </td>
                    <td>{{ item.date }}</td>
                    <td>{{ item.view_counter }}</td>
                    <td>
                        <a href="{{ buildUrl('newsManager/modify')~'?id='~item.id }}">
                            <span class="label label-primary">modify</span>
                        </a>
                        <a href="{{ buildUrl('newsManager/delete')~'?id='~item.id }}">
                            <span class="label label-danger">delete</span>
                        </a>
                    </td>
                </tr>
            {% endfor %}
            </tbody>
        </table>
    {% endif %}
    {% include "common/pagenation.html" %}
{% endblock %}
{% block js %}
    <script src="{{ buildStaticUrl("/js/news_manager/addnews.js") }}"></script>
{% endblock %}